import Page
from Page import Music
from Base.Base import Base
from selenium.webdriver.common.by import By


class MusicPlayerPage(Base):
    """
    音乐-播放器页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 返回键
        self.player_back_btn = (By.XPATH, Music.RESOURCE_ID.format("activity_player_back"))

        # 播放的歌曲名
        self.player_song_name_text = (By.XPATH, Music.RESOURCE_ID.format("tv_music_name"))

        # 收藏按钮
        self.player_collection_btn = (By.XPATH, Music.RESOURCE_ID.format("iv_favourite"))

        # 上一曲
        self.player_previous_btn = (By.XPATH, Music.RESOURCE_ID.format("iv_previous"))

        # 播放键
        self.player_play_btn = (By.XPATH, Music.RESOURCE_ID.format("iv_play"))

        # 下一曲
        self.player_next_btn = (By.XPATH, Music.RESOURCE_ID.format("iv_next"))

        # 歌词按钮
        self.player_lyric_btn = (By.XPATH, Music.RESOURCE_ID.format("iv_lyric"))

        # TODO - 优先级: 中 - 任务: 完善播放器右侧元素

    def get_collection_icon(self):
        """
        获取收藏按钮

        :return: 元素对象
        """

        return self.find_element_o(self.player_collection_btn)

    def get_song_name(self):
        """
        获取当前播放音乐的歌曲名

        :return:
        """
        return self.find_element_o(self.player_song_name_text)

    def click_player_back(self):
        """
        点击左上角的返回, 返回首页

        :return: None
        """
        self.click_element(self.player_back_btn)

    def click_collection(self):
        """
        点击收藏icon

        :return:
        """
        self.click_element(self.player_collection_btn)

    def click_play(self):
        """
        点击播放icon

        :return:
        """
        self.click_element(self.player_play_btn)
